﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
//using System.Net.Mail;

public partial class Templates_Contact_Default : Acms.AcmsControls.TemplatePage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        btnSubmit.Click += new EventHandler(btnSubmit_Click);
    }

    void btnSubmit_Click(object sender, EventArgs e)
    {
        Validate();
        
if (IsValid)
        {
            //create the mail message
            //MailMessage mail = new MailMessage();
            System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();

            //set the addresses
            mail.To.Add(new System.Net.Mail.MailAddress("hannah@eyeobserve.co.uk", "Hannah Spackman"));
            //mail.To.Add("you@yourcompany.com");
            mail.From = new System.Net.Mail.MailAddress(txtEmail.Text, txtName.Text);
            mail.Bcc.Add(new System.Net.Mail.MailAddress("acmsemail@gmail.com", "Acms Acms"));
            
            //mail.Bcc = "me@me.com";
            //System.Net.Mail.MailAddress izabelle = new System.Net.Mail.MailAddress("acmsemail@gmail.com", "Acms Email");
            //mail.Bcc.Add(izabelle);
         
            //   mail.Bcc.Add("acmsemail@googlemail.com");
            
            //mail.Bcc.Add(bcc);

            //mail.Bcc = "acmsemail@gmail.com";
            //set the content
            mail.Subject = string.Concat("Email from eyeobserve - ", txtSubject.Text);
            mail.Body = txtQuestion.Text;

            //send the message
            //SmtpClient smtp = new System.Net.Mail.SmtpClient();
            //smtp.Send(mail);

            try
            {
                System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient();
                client.Send(mail);
                mail.Dispose();
                pnlMessageSent.Visible = true;
                pnlCreateMsg.Visible = false;

            }
            catch
            {
                pnlCreateMsg.Visible = false;
                pnlMessageError.Visible = true;
            }
        }
    }
}
